<div class="container">

    <?php echo $this->element('page_header'); ?>

    <div class="row">
        <div class="span2">
            <?php echo $this->element('tickets/navigation'); ?>
        </div>
        <div class="span10">

            <div class="widget">

                <div class="widget-header">
                    <h3>
                        <i class="icon-th-list"></i>
                        New Ticket Form
                    </h3>
                </div> <!-- /widget-header -->

                <div class="widget-content" style="padding-top: 0px;">
                    <?php
                    $error = false;
                    if($this->Session->check('process_error')){
                        if($this->Session->read('process_error') == 'yes'){
                            $error = true;
                        }
                        $controller->Session->delete('process_error');
                    }
                    ?>
                    <?php
                    $flash_msg = $this->Session->read('Message');
                    if(isset($flash_msg['flash'])){
                        ?>
                        <div class="row-fluid">
                            <div class="span12">
                                <?php
                                if($error){
                                    echo $this->Message->msg('Status',$this->Session->flash(),'error',true);
                                }
                                else{
                                    echo $this->Message->msg('Status',$this->Session->flash(),'success',true);
                                }
                                ?>
                            </div>
                        </div>
                    <?php
                    }
                    ?>
                    <?php echo $this->Form->create('Ticket', array('type' => 'file','id' => 'form','class'=>'form-horizontal'));?>
                    <fieldset>
                        <legend>Details</legend>
                        <div class="control-group">
                            <label class="control-label" for="subject">Subject</label>
                            <div class="controls">
                                <?php echo $this->Form->input('subject', array('id' => 'subject', 'required' => 'required', 'value'=>$default_data['subject'],'class' => 'span6', 'div' => false, 'label' => false)); ?>
                            </div>
                        </div>
                        <div class="control-group">
                            <div class="control-inner-group">
                                <label class="control-label" for="project_id">Project</label>
                                <div class="controls">
                                    <?php echo $this->Form->input('project_id', array('id' => 'project_id', 'required' => 'required', 'options' => $projects, 'value'=>$default_data['project_id'],'class' => 'span3', 'div' => false, 'label' => false)); ?>
                                </div>
                            </div>
                            <div class="control-inner-group">
                                <label class="control-label" for="status_id">Status</label>
                                <div class="controls">
                                    <?php echo $this->Form->input('status_id', array('id' => 'status_id', 'required' => 'required', 'options' => $status, 'value'=>$default_data['status_id'],'class' => 'span2', 'div' => false, 'label' => false)); ?>
                                </div>
                            </div>
                        </div>

                        <div class="control-group">
                           <!-- <div class="control-inner-group">
                                <label class="control-label" for="user_id">Assign To</label>
                                <div class="controls">
                                    <?php /*echo $this->Form->input('user_id', array('id' => 'user_id', 'required' => 'required', 'options' => $assign_to, 'value'=>$default_data['assign_to'],'class' => 'span3', 'div' => false, 'label' => false)); */?>
                                </div>
                            </div>-->
                            <div class="control-inner-group">
                                <label class="control-label" for="priority">Priority</label>
                                <div class="controls">
                                    <?php echo $this->Form->input('priority_id', array('id' => 'priority_id', 'required' => 'required', 'options' => $priorities, 'value'=>$default_data['priority_id'],'class' => 'span2', 'div' => false, 'label' => false)); ?>
                                </div>
                            </div>
                        </div>

                        <div class="control-group">
                            <label class="control-label" for="comments">Comments</label>
                            <div class="controls">
                                <?php echo $this->Form->input('comments', array('type'=>'textarea','id' => 'comments', 'required' => 'required', 'value'=>$default_data['comments'], 'class' => 'span6', 'div' => false, 'label' => false)); ?>
                            </div>
                        </div>
                        <div class="control-group">
                            <!--<label class="control-label" for="notify_list">Notify List</label>

                            <span id="dualselect" class="dualselect">
                                <select name="data[Ticket][notify_list][]" id="notify_list" multiple="multiple" size="10">
                                </select>
                              <?php //echo $this->Form->input('notify_list', array('type'=>'select' ,'id' => 'notify_list','multiple'=>'multiple', 'size'=>'10', 'div' => false, 'label' => false)); ?>

                                <span class="ds_arrow">
                                    <button class="btn ds_prev"><i class="icon-arrow-left"></i></button><br /><br />
                                    <button class="btn ds_next"><i class="icon-arrow-right"></i></button>
                                </span>
                                 <?php /*echo $this->Form->input('user_list', array('id' => 'user_list', 'options' => $assign_to, 'class' => 'uniformselect','multiple'=>'multiple', 'size'=>'10', 'div' => false, 'label' => false)); */?>
                            </span>-->

                            <?php echo $this->Form->input('id', array('type'=>'hidden', 'value'=>$default_data['ticket_id'], 'div' => false, 'label' => false)); ?>
                            <?php echo $this->Form->input('branch_id', array('type'=>'hidden','id'=>'branch_id', 'value'=>$default_data['branch_id'], 'div' => false, 'label' => false)); ?>
                            <?php echo $this->Form->input('department_id', array('type'=>'hidden','id'=>'department_id', 'value'=>$default_data['department_id'], 'div' => false, 'label' => false)); ?>
                            <?php echo $this->Form->input('created_by', array('type'=>'hidden', 'value'=>$default_data['created_by'], 'div' => false, 'label' => false)); ?>
                            <?php echo $this->Form->input('modified_by', array('type'=>'hidden', 'value'=>$default_data['modified_by'], 'div' => false, 'label' => false)); ?>
                        </div>
                    </fieldset>

                    <fieldset>
                        <legend>Project Management</legend>
                       <!-- <div class="control-group">
                            <label class="control-label" for="due_dt">Requested Due Date</label>
                            <div class="controls">
                                <?php /*echo $this->Form->input('due_dt', array('id' => 'due_dt', 'required' => 'required', 'value' => '', 'div' => false, 'label' => false)); */?>
                            </div>
                        </div>-->

                        <div class="control-group">
                            <div class="control-inner-group">
                                <label class="control-label" for="due_dt">Requested Due Date</label>
                                <div class="controls">
                                    <?php echo $this->Form->input('due_dt', array('type'=>'text','id' => 'due_dt', 'class' => 'span3','required' => 'required', 'placeholder' => 'YYYY-MM-DD', 'div' => false, 'label' => false));?>
                                </div>
                            </div>

                            <div class="control-inner-group">
                                <label class="control-label" for="estimated_hrs">Estimated Hours</label>
                                <div class="controls">
                                    <div class="input-append">
                                        <?php echo $this->Form->input('estimated_hrs', array('type'=>'text','id' => 'estimated_hrs', 'class' => 'span2' ,'value' => '', 'div' => false, 'label' => false)); ?>
                                        <span class="add-on">hr(s)</span>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </fieldset>

                    <fieldset>
                        <legend>Attachments</legend>
                        <div class="control-group">
                            <label class="control-label" for="due_dt">Add Attachments</label>
                            <div class="controls">
                                <?php echo $this->Form->input('attach', array('type' => 'file','id' => 'attach', 'div' => false, 'label' => false)); ?>
                            </div>
                        </div>
                    </fieldset>

                    <fieldset>
                        <div class="form-actions">
                            <button type="submit" class="btn btn-primary btn-large">Create Ticket</button>
                            <button type="reset" class="btn btn-large">Cancel</button>
                        </div>
                    </fieldset>
                    <?php echo $this->Form->end();?>
                </div> <!-- /widget-content -->

            </div> <!-- /widget -->

        </div>

    </div> <!-- /.row -->

</div> <!-- /.container -->

<script type="text/javascript">
    var gblProjectMoreData = <?php echo json_encode($project_more_data);?>;
</script>

<?php
    echo $this->Html->script('Scripts/ticket_create.js');
?>